function getnum() {
    var arr = localStorage.getItem('car')?JSON.parse(localStorage.getItem('car')):[];
var num = 0;
arr.forEach(element => {
    num+=element.count;
});
if(localStorage.getItem('user_info')){
    return num;
}else{
    return 0;
}
  }
const init={
    count:getnum()
}

exports.reducer = (state=init,action)=>{
    console.log(action)
    switch(action.type){
        case 'add_action':
            console.log(getnum())
            return{
                count:getnum()
            }
            default:
                return state;
    }
    return state;
}